package com.yociyy.admin.model.dto;

import com.yociyy.admin.model.entity.BaseDept;
import com.yociyy.admin.model.entity.BaseRole;
import com.yociyy.admin.model.entity.BasePost;
import com.yociyy.admin.model.entity.BaseUser;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Transient;
import java.io.Serializable;
import java.util.List;

/**
 * 用户信息 Dto
 * 
 * @author: YoCiyy
 * @date: 2020/4/16
 */
@Data
@Accessors(chain = true)
public class UserDto extends BaseUser implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 部门对象
	 */
	@Transient
	private BaseDept dept;

	/**
	 * 角色对象
	 */
	@Transient
	private List<BaseRole> roles;

	/**
	 * 角色对象
	 */
	@Transient
	private List<BasePost> posts;

	/**
	 * 角色组
	 */
	@Transient
	private List<Long> roleIds;

	/**
	 * 岗位组
	 */
	@Transient
	private List<Long> postIds;

	/**
	 * 判断是否是超级管理员
	 */
	@Override
	public boolean isAdmin() {
		return isAdmin(id);
	}

	public static boolean isAdmin(Long userId) {
		return userId != null && 1L == userId;
	}

}
